package org.jetnuke.modules.download;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.velocity.VelocityContext;
import org.jetnuke.common.ActionForward;
import org.jetnuke.common.IAction;
import org.jetnuke.common.IAdminInfo;
import org.jetnuke.common.IModuleInfo;
import org.jetnuke.common.IUserInfo;
import org.jetnuke.dao.DataAccessDriver;
import org.jetnuke.entities.DownloadsNewDownload;
import org.jetnuke.util.JetUtil;

public class InsDownload implements IAction {
	String title, url, description, name, email, version, home;

	int parent, filesize;

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.jetnuke.common.IAction#exec(javax.servlet.http.HttpServletRequest,
	 *      javax.servlet.http.HttpServletResponse,
	 *      org.apache.velocity.VelocityContext, org.jetnuke.common.IModuleInfo,
	 *      java.lang.String, org.jetnuke.common.IUserInfo,
	 *      org.jetnuke.common.IAdminInfo)
	 */
	public ActionForward exec(HttpServletRequest request,
			HttpServletResponse response, VelocityContext vc, IModuleInfo info,
			String op, IUserInfo ui, IAdminInfo ai) throws Exception {
		DownloadsNewDownload dd = new DownloadsNewDownload();
		dd.setDESCRIPTION(description);
		dd.setEMAIL(email);
		dd.setFILESIZE(filesize);

		dd.setHOMEPAGE(home);
		dd.setNAME(name);
		dd.setCID(parent);
		dd.setTITLE(title);
		dd.setURL(url);
		dd.setSUBMITTER("");
		dd.setVERSION(version);
		dd.setSID(0);
		DataAccessDriver.getInst().newDownloadNewDownloadDAO().addNew(dd);
		//dd.save();
		JetUtil.redirect(vc,response,request.getContextPath()+"/do/download");//TODO
		return null;
	}

	/**
	 * @param description
	 *            The description to set.
	 */
	public void setDescription(String description) {
		this.description = description;
	}

	/**
	 * @param email
	 *            The email to set.
	 */
	public void setEmail(String email) {
		this.email = email;
	}

	/**
	 * @param filesize
	 *            The filesize to set.
	 */
	public void setFilesize(int filesize) {
		this.filesize = filesize;
	}

	/**
	 * @param home
	 *            The home to set.
	 */
	public void setHome(String home) {
		this.home = home;
	}

	/**
	 * @param name
	 *            The name to set.
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * @param parent
	 *            The parent to set.
	 */
	public void setParent(int parent) {
		this.parent = parent;
	}

	/**
	 * @param title
	 *            The title to set.
	 */
	public void setTitle(String title) {
		this.title = title;
	}

	/**
	 * @param url
	 *            The url to set.
	 */
	public void setUrl(String url) {
		this.url = url;
	}

	/**
	 * @param version
	 *            The version to set.
	 */
	public void setVersion(String version) {
		this.version = version;
	}
}
